<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('Wechat/editPublic')}">基本信息配置</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('Wechat/saveEditPublic')}">

        <input type="hidden" name="id" value="{$info.id | default = ''}">
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>公众号名称:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="name" value="{$info.name | default = ''}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">公众号头像:</label>
            <div class="col-md-6 col-sm-10">
                <input type="file" class="form-control" name="imgsrc">
                <notempty name="$info['imgsrc']">
                   <img src="<?php echo cmf_get_image_url($info['imgsrc'])?>" style="width: 100px;border: 1px solid;margin: 10px;">
                </notempty>

            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>公众号账号:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="account" value="{$info.account | default = ''}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>原始ID:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="primitiveId" value="{$info.primitiveId | default = ''}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>appId:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="app_id" value="{$info.app_id | default = ''}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>appSecret:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="app_secret" value="{$info.app_secret | default = ''}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>token:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="token" value="{$info.token | default = ''}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>aes_key:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="aes_key" value="{$info.aes_key | default = ''}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>商户号:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="merchant_id" value="{$info.merchant_id | default = ''}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>秘钥:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="key" value="{$info.key | default = ''}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>模板消息ID:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="temp_id" value="{$info.temp_id | default = ''}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>联系电话:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="phone" value="{$info.phone | default = ''}">
            </div>
        </div>


        <div class="form-group row">
            <label class="col-sm-2 control-label">所属行政区</label>
            <div class="col-sm-2">
                <select name="province" id="province" class="form-control">
                    <option value="{$info.provinceID|default=''}">{$info.pName|default=''}</option>
                </select>
            </div>
            <div class="col-sm-2">
                <select name="city" id="city" class="form-control">
                    <option value="{$info.cityID|default=''}">{$info.cityName|default=''}</option>
                </select>
            </div>
            <div class="col-sm-2">
                <select name="area" id="area" class="form-control">
                    <option value="{$info.areaID|default=''}">{$info.areaName|default=''}</option>
                </select>
            </div>
        </div>

        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-primary js-ajax-submit">{:lang("SAVE")}</button>
        </div>
    </form>

</div>
<script src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            url: "{:url('portal/mei/san')}",
            data: {},
            dataType:"json",
            success: function(res){
                var html = '';
                var data = res['data'];
                if(data != ''){
                    $.each(data,function(index,value){
                        html += '<option value="'+data[index]['provinceID']+'">'+data[index]['province']+'</option>';
                    });
                    $("#province").append(html);
                }
            }
        });

        $("#province").change(function(){
            var provinceID = $("#province option:selected").val();
            $.ajax({
                type: "POST",
                url: "{:url('portal/mei/san')}",
                data: {provinceID:provinceID},
                dataType:"json",
                success: function(res){
                    console.log(res);
                    var html = '';
                    $("#city").html('');
                    var data = res['data'];
                    if(data != ''){
                        $.each(data,function(index,value){
                            html += '<option value="'+data[index]['cityID']+'">'+data[index]['city']+'</option>';
                        });
                        $("#city").append(html);
                    }
                }
            });
        });

        $("#city").change(function(){
            var cityID = $("#city option:selected").val();
            console.log(cityID);
            $.ajax({
                type: "POST",
                url: "{:url('portal/mei/san')}",
                data: {cityID:cityID},
                dataType:"json",
                success: function(res){
                    console.log(res);
                    var html = '';
                    $("#area").html('');
                    var data = res['data'];
                    if(data != ''){
                        $.each(data,function(index,value){
                            html += '<option value="'+data[index]['areaID']+'">'+data[index]['area']+'</option>';
                        });
                        $("#area").append(html);
                    }
                }
            });
        });
    });
</script>
</body>
</html>